<?
/* 	These code was generated using phpCIGen v 0.1.b (1/08/2009)
	#zaqi 		zaqi.smart@gmail.com,http://zenzaqi.blogspot.com,
	#CV. Trust Solution, jl. Saronojiwo 19 Surabaya, http://www.ts.co.id

	+ Module  		: t_order View
	+ Description	: For record view
	+ Filename 		: v_t_order.php
 	+ Author  		: 
 	+ Created on 05/Mar/2012 14:57:56

*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<style type="text/css">
        p { width:650px; }
		.search-item {
			font:normal 11px tahoma, arial, helvetica, sans-serif;
			padding:3px 10px 3px 10px;
			border:1px solid #fff;
			border-bottom:1px solid #eeeeee;
			white-space:normal;
			color:#555;
		}
		.search-item h3 {
			display:block;
			font:inherit;
			font-weight:bold;
			color:#222;
		}

		.search-item h3 span {
			float: right;
			font-weight:normal;
			margin:0 0 5px 5px;
			width:100px;
			display:block;
			clear:none;
		}
    </style>
<script>
/* declare function */
var t_order_DataStore;
var t_order_ColumnModel;
var t_order_ListEditorGrid;
var t_order_saveForm;
var t_order_saveWindow;
var t_order_searchForm;
var t_order_searchWindow;
var t_order_SelectedRow;
var t_order_ContextMenu;
//for detail data
var t_orderdet_DataStore;
var t_orderdet_ListEditorGrid;
var t_orderdet_ColumnModel;
var t_orderdet_proxy;
var t_orderdet_writer;
var t_orderdet_reader;
var editor_t_orderdet;
/* decalare KONSTANSTA */
var FAILED_SAVE="Data gagal disimpan";
var FAILED_CONNECTION="Koneksi database server gagal, hubungi Administrator";
var FAILED_VALID_FORM="Data input belum sempurna";
var FAILED_DELETE_SELECTED="Tidak ada data yang terpilih untuk dihapus";
var FAILED_UPDATE_SELECTED="Tidak ada data yang terpilih untuk diupdate";
var FAILED_DELETE="Data gagal dihapus";
var FAILED_EXCEL="Data gagal diexport ke Excel";
var FAILED_PRINT="Data gagal dicetak";
var FAILED_PERMISSION="Anda tidak mempunyai akses untuk aksi ini";
var CONFIRM_DELETE="Apakah Anda yakin menghapus rekod ini?";
var CONFIRM_MULTI_DELETE="Apakah Anda yakin menghapus rekod-rekod ini?";
var WAIT_MESSAGE="Mohon tunggu, masih dalam pemrosesan";
var FAILED_NULL_DATA="Data detail belum ada";
var SUCCESS_SAVE="Data sukses disimpan";
var TITLE_LIST="Daftar Data";
var TITLE_FORM="Form Input/Update";
var TITLE_FORM_SEARCH="Pencarian Lanjut";
var TITLE_LIST_DETAIL="Daftar Data Detail";
var BTN_SAVE="Simpan";
var BTN_SEARCH="Cari";
var BTN_CANCEL="Batal";
var BTN_ADD_TITLE="Tambah";
var BTN_EDIT_TITLE="Ubah";
var BTN_DELETE_TITLE="Hapus";
var BTN_SEARCH_TITLE="Pencarian";
var BTN_PRINT_TITLE="Cetak";
var BTN_EXCEL_TITLE="Export Excel";
var BTN_REFRESH_TITLE="Refresh";
var BTN_ADD_TOOLTIP="Tambah Data Baru";
var BTN_EDIT_TOOLTIP="Ubah Data";
var BTN_DELETE_TOOLTIP="Hapus Data";
var BTN_SEARCH_TOOLTIP="Pencarian Lanjut Data";
var BTN_SIMPLE_SEARCH_TOOLTIP="Pencarian Sederhana";
var BTN_PRINT_TOOLTIP="Cetak Data (hmtl)";
var BTN_EXCEL_TOOLTIP="Export ke bentuk Excel";
var BTN_REFERSH_TOOLTIP="Refresh Data";
var INFO_REQUIRED="Wajib diisi";
var PERMISSION="RCUD";
//declare konstant
var post2db = 'CREATE';
var msg = 'created';
var pageS=15;

/* declare variable here for Field*/
var order_idField;
var order_codeField;
var order_dateField;
var order_duedateField;
var m_customer_idField;
var m_staff_idField;
var order_statField;
var order_noteField;
var order_idSearchField;
var order_codeSearchField;
var order_dateSearchField;
var order_duedateSearchField;
var m_customer_idSearchField;
var m_staff_idSearchField;
var order_statSearchField;
var order_noteSearchField;

/* on ready fuction */
Ext.onReady(function(){
  	Ext.QuickTips.init();	/* Initiate quick tips icon */

  	/* Function for Saving inLine Editing */
	function t_order_inline_update(oGrid_event){

	var patt=new RegExp("U");
	if(patt.test(PERMISSION)==false){

		Ext.MessageBox.show({
		   title: 'Warning',
		   msg: FAILED_PERMISSION,
		   buttons: Ext.MessageBox.OK,
		   animEl: 'security',
		   icon: Ext.MessageBox.WARNING
		});

	}else{

		var order_id_update=null;
		var order_code_update=null;
		var order_date_update_date="";
		var order_duedate_update_date="";
		var m_customer_id_update=null;
		var m_staff_id_update=null;
		var order_stat_update=null;
		var order_note_update=null;

		if(oGrid_event.record.data.order_id!== null){order_id_update = oGrid_event.record.data.order_id;}
		if(oGrid_event.record.data.order_code!== null){order_code_update = oGrid_event.record.data.order_code;}
	 	if(oGrid_event.record.data.order_date!== ""){order_date_update_date =oGrid_event.record.data.order_date.format('Y-m-d');}
	 	if(oGrid_event.record.data.order_duedate!== ""){order_duedate_update_date =oGrid_event.record.data.order_duedate.format('Y-m-d');}
		if(oGrid_event.record.data.m_customer_id!== null){m_customer_id_update = oGrid_event.record.data.m_customer_id;}
		if(oGrid_event.record.data.m_staff_id!== null){m_staff_id_update = oGrid_event.record.data.m_staff_id;}
		if(oGrid_event.record.data.order_stat!== null){order_stat_update = oGrid_event.record.data.order_stat;}
		if(oGrid_event.record.data.order_note!== null){order_note_update = oGrid_event.record.data.order_note;}

		Ext.Ajax.request({
			waitMsg: 'Please wait...',
			url: 'index.php?c=c_t_order&m=get_action',
			params: {
				order_id	:order_id_update,
				order_code	:order_code_update,
				order_date	: order_date_update_date,
				order_duedate	: order_duedate_update_date,
				m_customer_id	:m_customer_id_update,
				m_staff_id	:m_staff_id_update,
				order_stat	:order_stat_update,
				order_note	:order_note_update,
				task: "UPDATE"
			},
			success: function(response){
				var result=eval(response.responseText);
				switch(result){
					case 1:
						t_order_DataStore.commitChanges();
						t_order_DataStore.reload();
						break;
					default:
						Ext.MessageBox.show({
						   title: 'Warning',
						   msg: FAILED_SAVE,
						   buttons: Ext.MessageBox.OK,
						   animEl: 'save',
						   icon: Ext.MessageBox.WARNING
						});
						break;
				}
			},
			failure: function(response){
				var result=response.responseText;
				Ext.MessageBox.show({
				   title: 'Error',
				   msg: FAILED_CONNECTION,
				   buttons: Ext.MessageBox.OK,
				   animEl: 'database',
				   icon: Ext.MessageBox.ERROR
				});
			}
		});

		}
	}
  	/* End of Function */

  	/* Function for add and edit data form, open window form */
	function t_order_save(){

		var patt=new RegExp("U");
		var patt2=new RegExp("C");
		if(patt.test(PERMISSION)==false && patt2.test(PERMISSION)==false){

			Ext.MessageBox.show({
			   title: 'Warning',
			   msg: FAILED_PERMISSION,
			   buttons: Ext.MessageBox.OK,
			   animEl: 'security',
			   icon: Ext.MessageBox.WARNING
			});

		}else{

		if(is_t_order_form_valid()){
			var order_id_field=null;
			var order_code_field=null;
			var order_date_field_date="";
			var order_duedate_field_date="";
			var m_customer_id_field=null;
			var m_staff_id_field=null;
			var order_stat_field=null;
			var order_note_field=null;

			if(order_idField.getValue()!== null){order_id_field = order_idField.getValue();}
			if(order_codeField.getValue()!== null){order_code_field = order_codeField.getValue();}
			if(order_dateField.getValue()!== ""){order_date_field_date = order_dateField.getValue().format('Y-m-d');}
			if(order_duedateField.getValue()!== ""){order_duedate_field_date = order_duedateField.getValue().format('Y-m-d');}
			if(m_customer_idField.getValue()!== null){m_customer_id_field = m_customer_idField.getValue();}
			if(m_staff_idField.getValue()!== null){m_staff_id_field = m_staff_idField.getValue();}
			if(order_statField.getValue()!== null){order_stat_field = order_statField.getValue();}
			if(order_noteField.getValue()!== null){order_note_field = order_noteField.getValue();}
			/* add detail data */
					var orderdet_id = [];
		var t_order_id = [];
		var orderdet_detail = [];
		var orderdet_qty = [];
		var orderdet_price = [];

        if(t_orderdet_DataStore.getCount()>0){
            for(i=0; i<t_orderdet_DataStore.getCount();i++){
                if(
        		t_orderdet_DataStore.getAt(i).data.orderdet_id!==undefined  &&
		    	    		t_orderdet_DataStore.getAt(i).data.orderdet_detail!==undefined  &&
		    		t_orderdet_DataStore.getAt(i).data.orderdet_qty!==undefined  &&
		    		t_orderdet_DataStore.getAt(i).data.orderdet_price!==undefined 
						   ){
				        orderdet_id.push(t_orderdet_DataStore.getAt(i).data.orderdet_id);
                		        		        orderdet_detail.push(t_orderdet_DataStore.getAt(i).data.orderdet_detail);
                		        orderdet_qty.push(t_orderdet_DataStore.getAt(i).data.orderdet_qty);
                		        orderdet_price.push(t_orderdet_DataStore.getAt(i).data.orderdet_price);
                                }
            }
			var encoded_array_orderdet_id = Ext.encode(orderdet_id);
			var encoded_array_t_order_id = Ext.encode(t_order_id);
			var encoded_array_orderdet_detail = Ext.encode(orderdet_detail);
			var encoded_array_orderdet_qty = Ext.encode(orderdet_qty);
			var encoded_array_orderdet_price = Ext.encode(orderdet_price);

			Ext.Ajax.request({
				waitMsg: 'Please wait...',
				url: 'index.php?c=c_t_order&m=get_action',
				params: {
					order_id	: order_id_field,
					order_code	: order_code_field,
					order_date	: order_date_field_date,
					order_duedate	: order_duedate_field_date,
					m_customer_id	: m_customer_id_field,
					m_staff_id	: m_staff_id_field,
					order_stat	: order_stat_field,
					order_note	: order_note_field,
			
					orderdet_id		: encoded_array_orderdet_id,
					orderdet_detail		: encoded_array_orderdet_detail,
					orderdet_qty		: encoded_array_orderdet_qty,
					orderdet_price		: encoded_array_orderdet_price,
					task: post2db
				},
				success: function(response){
					var result=eval(response.responseText);
					if(result===1){
						t_order_DataStore.reload();
						t_order_reset_form();
						t_order_saveWindow.hide();
						Ext.MessageBox.alert(post2db+' OK',SUCCESS_SAVE);
				    }else{
							Ext.MessageBox.show({
							   title: 'Warning',
							   msg: FAILED_SAVE,
							   buttons: Ext.MessageBox.OK,
							   animEl: 'save',
							   icon: Ext.MessageBox.WARNING
							});
					}
				},
				failure: function(response){
					var result=response.responseText;
					Ext.MessageBox.show({
						   title: 'Error',
						   msg: FAILED_CONNECTION,
						   buttons: Ext.MessageBox.OK,
						   animEl: 'database',
						   icon: Ext.MessageBox.ERROR
					});
				}
			});
		}else{
			Ext.MessageBox.show({
				title: 'Warning',
				msg: FAILED_NULL_DATA,
				buttons: Ext.MessageBox.OK,
				animEl: 'save',
				icon: Ext.MessageBox.WARNING
			});
		}
		} else {
			Ext.MessageBox.show({
				title: 'Warning',
				msg: FAILED_VALID_FORM,
				buttons: Ext.MessageBox.OK,
				animEl: 'save',
				icon: Ext.MessageBox.WARNING
			});
		}

		}
	}
 	/* End of Function */

  	/* Function for get PK field */
	function get_pk_id(){
		if(post2db=='UPDATE')
			return t_order_ListEditorGrid.getSelectionModel().getSelected().get('order_id');
		else
			return 0;
	}
	/* End of Function  */

	/* Reset form before loading */
	function t_order_reset_form(){
		order_idField.reset();
		order_idField.setValue(null);
		order_codeField.reset();
		order_codeField.setValue(null);
		order_dateField.reset();
		order_dateField.setValue(null);
		order_duedateField.reset();
		order_duedateField.setValue(null);
		m_customer_idField.reset();
		m_customer_idField.setValue(null);
		m_staff_idField.reset();
		m_staff_idField.setValue(null);
		order_statField.reset();
		order_statField.setValue(null);
		order_noteField.reset();
		order_noteField.setValue(null);
	}
 	/* End of Function */

	/* setValue to EDIT */
	function t_order_set_form(){
		order_idField.setValue(t_order_ListEditorGrid.getSelectionModel().getSelected().get('order_id'));
		order_codeField.setValue(t_order_ListEditorGrid.getSelectionModel().getSelected().get('order_code'));
		order_dateField.setValue(t_order_ListEditorGrid.getSelectionModel().getSelected().get('order_date'));
		order_duedateField.setValue(t_order_ListEditorGrid.getSelectionModel().getSelected().get('order_duedate'));
		m_customer_idField.setValue(t_order_ListEditorGrid.getSelectionModel().getSelected().get('m_customer_id'));
		m_staff_idField.setValue(t_order_ListEditorGrid.getSelectionModel().getSelected().get('m_staff_id'));
		order_statField.setValue(t_order_ListEditorGrid.getSelectionModel().getSelected().get('order_stat'));
                if(t_order_ListEditorGrid.getSelectionModel().getSelected().get('order_stat') == 'a'){
                    order_statField.setValue('Order');
                }else if(t_order_ListEditorGrid.getSelectionModel().getSelected().get('order_stat') == 'b'){
                    order_statField.setValue('Produksi');
                }else if(t_order_ListEditorGrid.getSelectionModel().getSelected().get('order_stat') == 'c'){
                    order_statField.setValue('Ditagihkan');
                }else{
                    order_statField.setValue('Terbayar/Lunas');
                };
		order_noteField.setValue(t_order_ListEditorGrid.getSelectionModel().getSelected().get('order_note'));
                t_orderdet_DataStore.setBaseParam('master_id',get_pk_id());
		t_orderdet_DataStore.load();
	}
	/* End setValue to EDIT*/

	/* Function for Check if the form is valid */
	function is_t_order_form_valid(){
		return (true
			);
	}
  	/* End of Function */

  	/* Function for Displaying  create Window Form */
	function display_form_window(){
		if(!t_order_saveWindow.isVisible()){
			post2db='CREATE';
			msg='created';
			t_order_reset_form();
			t_order_saveWindow.show();
		} else {
			t_order_saveWindow.toFront();
		}
	}
  	/* End of Function */

  	/* Function for Delete Confirm */
	function t_order_confirm_delete(){
		// only one t_order is selected here
		if(t_order_ListEditorGrid.selModel.getCount() == 1){
			Ext.MessageBox.confirm('Confirmation',CONFIRM_DELETE, t_order_delete);
		} else if(t_order_ListEditorGrid.selModel.getCount() > 1){
			Ext.MessageBox.confirm('Confirmation',CONFIRM_MULTI_DELETE, t_order_delete);
		} else {
			Ext.MessageBox.show({
				title: 'Warning',
				msg: FAILED_DELETE_SELECTED,
				buttons: Ext.MessageBox.OK,
				animEl: 'save',
				icon: Ext.MessageBox.WARNING
			});
		}
	}
  	/* End of Function */

	/* Function for Update Confirm */
	function t_order_confirm_update(){
		/* only one record is selected here */
		if(t_order_ListEditorGrid.selModel.getCount() == 1) {
			post2db='UPDATE';
			msg='updated';
			t_order_set_form();
                        t_order_saveWindow.show();
		} else {
			Ext.MessageBox.show({
				title: 'Warning',
				msg: FAILED_UPDATE_SELECTED,
				buttons: Ext.MessageBox.OK,
				animEl: 'save',
				icon: Ext.MessageBox.WARNING
			});
		}
	}
  	/* End of Function */

  	/* Function for Delete Record */
	function t_order_delete(btn){
		if(btn=='yes'){

		var patt=new RegExp("D");
		if(patt.test(PERMISSION)==false){

			Ext.MessageBox.show({
			   title: 'Warning',
			   msg: FAILED_PERMISSION,
			   buttons: Ext.MessageBox.OK,
			   animEl: 'security',
			   icon: Ext.MessageBox.WARNING
			});

		}else{

			var selections = t_order_ListEditorGrid.selModel.getSelections();
			var prez = [];
			for(i = 0; i< t_order_ListEditorGrid.selModel.getCount(); i++){
				prez.push(selections[i].json.order_id);
			}
			var encoded_array = Ext.encode(prez);
			Ext.Ajax.request({
				waitMsg: 'Please Wait',
				url: 'index.php?c=c_t_order&m=get_action',
				params: { task: "DELETE", ids:  encoded_array },
				success: function(response){
					var result=eval(response.responseText);
					switch(result){
						case 1:
							t_order_DataStore.reload();
							break;
						default:
							Ext.MessageBox.show({
								title: 'Warning',
								msg: FAILED_DELETE,
								buttons: Ext.MessageBox.OK,
								animEl: 'save',
								icon: Ext.MessageBox.WARNING
							});
							break;
					}
				},
				failure: function(response){
					var result=response.responseText;
					Ext.MessageBox.show({
					   title: 'Error',
					   msg: FAILED_CONNECTION,
					   buttons: Ext.MessageBox.OK,
					   animEl: 'database',
					   icon: Ext.MessageBox.ERROR
					});
				}
			});

			}

		}
	}
  	/* End of Function */


	/* Function for Retrieve DataStore */
	t_order_DataStore = new Ext.data.Store({
		id: 't_order_DataStore',
		proxy: new Ext.data.HttpProxy({
			url: 'index.php?c=c_t_order&m=get_action',
			method: 'POST'
		}),
		baseParams:{task: "LIST", start:0, limit: pageS},
		reader: new Ext.data.JsonReader({
			root: 'results',
			totalProperty: 'total',
			id: 'order_id'
		},[
		    {name: 'order_id', type: 'int', mapping: 'order_id'},
		    {name: 'order_code', type: 'string', mapping: 'order_code'},
		    {name: 'order_date', type: 'date', dateFormat: 'Y-m-d H:i:s', mapping: 'order_date'},
		    {name: 'order_duedate', type: 'date', dateFormat: 'Y-m-d H:i:s', mapping: 'order_duedate'},
		    {name: 'm_customer_id', type: 'string', mapping: 'customer_name'},
		    {name: 'm_staff_id', type: 'string', mapping: 'staff_name'},
		    {name: 'order_stat', type: 'string', mapping: 'order_stat'},
		    {name: 'order_note', type: 'string', mapping: 'order_note'}
		]),
		sortInfo:{field: 'order_id', direction: "DESC"}
	});
	/* End of Function */

  	/* Function for Identify of Window Column Model */
	t_order_ColumnModel = new Ext.grid.ColumnModel(
		[
		{
			header: 'Order Id',
			dataIndex: 'order_id',
			width: 150,
			sortable: true,
                        hidden: true,
			editor: new Ext.form.NumberField({
				allowDecimals: false,
					allowNegative: false,
				blankText: '0',
				maxLength: 11,
				maskRe: /([0-9]+)$/
			})
		},
		{
			header: 'No Order',
			dataIndex: 'order_code',
			width: 150,
			sortable: true,
			editor: new Ext.form.TextArea({
					height: 5
			})
		},
		{
			header: 'Tgl Order',
			dataIndex: 'order_date',
			width: 150,
			sortable: true,
			renderer: Ext.util.Format.dateRenderer('Y-m-d'),
			editor: new Ext.form.DateField({
					format: 'Y-m-d'
			})
		},
		{
			header: 'Tgl Selesai',
			dataIndex: 'order_duedate',
			width: 150,
			sortable: true,
			renderer: Ext.util.Format.dateRenderer('Y-m-d'),
			editor: new Ext.form.DateField({
					format: 'Y-m-d'
			})
		},
		{
			header: 'Klien',
			dataIndex: 'm_customer_id',
			width: 150,
			sortable: true,
			editor: new Ext.form.NumberField({
				allowDecimals: false,
					allowNegative: false,
				blankText: '0',
				maxLength: 11,
				maskRe: /([0-9]+)$/
			})
		},
		{
			header: 'Marketing',
			dataIndex: 'm_staff_id',
			width: 150,
			sortable: true,
			editor: new Ext.form.NumberField({
				allowDecimals: false,
					allowNegative: false,
				blankText: '0',
				maxLength: 11,
				maskRe: /([0-9]+)$/
			})
		},
		{
			header: 'Status',
			dataIndex: 'order_stat',
			width: 150,
			sortable: true,
			editor: new Ext.form.TextArea({
					height: 5
			})
		},
		{
			header: 'Catatan',
			dataIndex: 'order_note',
			width: 150,
			sortable: true,
			editor: new Ext.form.TextArea({
					height: 5
			})
		}	]);

	t_order_ColumnModel.defaultSortable= true;
	/* End of Function */

    /* Button Control */
    t_order_gbtn_add=new Ext.Button({
	    text: BTN_ADD_TITLE,
		tooltip: BTN_ADD_TOOLTIP,
		iconCls:'icon-adds',
		handler: display_form_window
    });

    t_order_gbtn_update=new Ext.Button({
	    text: BTN_EDIT_TITLE,
		tooltip: BTN_EDIT_TOOLTIP,
		iconCls:'icon-update',
		handler: t_order_confirm_update
	});

    t_order_gbtn_delete=new Ext.Button({
	    text: BTN_DELETE_TITLE,
		tooltip: BTN_DELETE_TOOLTIP,
		iconCls:'icon-delete',
		handler: t_order_confirm_delete
	});

    /*Context Menu Button */

	t_order_cbtn_update=new Ext.menu.Item({
		text: BTN_EDIT_TITLE,
		tooltip: BTN_EDIT_TOOLTIP,
		iconCls:'icon-update',
		handler: t_order_editContextMenu
	});

	t_order_cbtn_delete=new Ext.menu.Item({
		text: BTN_DELETE_TITLE,
		tooltip: BTN_DELETE_TOOLTIP,
		iconCls:'icon-delete',
		handler: t_order_confirm_delete
	});
	/* End of Function */

	/* Declare DataStore and  show datagrid list */
	t_order_ListEditorGrid =  new Ext.grid.EditorGridPanel({
		id: 't_order_ListEditorGrid',
		el: 'fp_t_order',
		title: TITLE_LIST,
		autoHeight: true,
		store: t_order_DataStore, // DataStore
		cm: t_order_ColumnModel, // Nama-nama Columns
		enableColLock:false,
		frame: true,
		//clicksToEdit:2, // 2xClick untuk bisa meng-Edit inLine Data
		selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
		viewConfig: { forceFit:true },
	  	width: 700,
		bbar: new Ext.PagingToolbar({
			pageSize: pageS,
			store: t_order_DataStore,
			displayInfo: true
		}),
		/* Add Control on ToolBar */
		tbar: [
		t_order_gbtn_add, '-',
		t_order_gbtn_update, '-',
		t_order_gbtn_delete, '-',
		{
			text: BTN_SEARCH_TITLE,
			tooltip: BTN_SEARCH_TOOLTIP,
			iconCls:'icon-search',
			handler: display_form_search_window
		}, '-',
		new Ext.app.SearchField({
			store: t_order_DataStore,
			listeners:{
				specialkey: function(f,e){
					if(e.getKey() == e.ENTER){
						t_order_DataStore.baseParams={task:'LIST', start:0, limit:pageS};
		            }
				},
				render: function(c){
				Ext.get(this.id).set({qtitle: BTN_SIMPLE_SEARCH_TOOLTIP});
				}
			},
			width: 120
		}),'-',{
			text: BTN_REFRESH_TITLE,
			tooltip: BTN_REFERSH_TOOLTIP,
			handler: t_order_reset_search,
			iconCls:'icon-refresh'
		},'-',{
			text: BTN_EXCEL_TITLE,
			tooltip: BTN_EXCEL_TOOLTIP,
			iconCls:'icon-xls',
			handler: t_order_export_excel
		}, '-',{
			text: BTN_PRINT_TITLE,
			tooltip: BTN_PRINT_TOOLTIP,
			iconCls:'icon-print',
			handler: t_order_print
		}
		]
	});
	t_order_ListEditorGrid.render();
	/* End of Grid */

	/* Create Context Menu */
	t_order_ContextMenu = new Ext.menu.Menu({
		id: 't_order_ContextMenu',
		items: [
		t_order_cbtn_update,
		t_order_cbtn_delete,
		'-',
		{
			text: BTN_PRINT_TITLE,
			tooltip: BTN_PRINT_TOOLTIP,
			iconCls:'icon-print',
			handler: t_order_print
		},
		{
			text: BTN_EXCEL_TITLE,
			tooltip: BTN_EXCEL_TOOLTIP,
			iconCls:'icon-xls',
			handler: t_order_export_excel
		}
		]
	});
	/* End of Declaration */

	/* Event while selected row via context menu */
	function ont_order_ContextMenu(grid, rowIndex, e) {
		e.stopEvent();
		var coords = e.getXY();
		t_order_ContextMenu.rowRecord = grid.store.getAt(rowIndex);
		grid.selModel.selectRow(rowIndex);
		t_order_SelectedRow=rowIndex;
		t_order_ContextMenu.showAt([coords[0], coords[1]]);
  	}
  	/* End of Function */

	/* function for editing row via context menu */
	function t_order_editContextMenu(){
		//t_order_ListEditorGrid.startEditing(t_order_SelectedRow,1);
		t_order_confirm_update();
  	}
	/* End of Function */

	t_order_ListEditorGrid.addListener('rowcontextmenu', ont_order_ContextMenu);
	t_order_DataStore.load({params: {start: 0, limit: pageS}});	// load DataStore
	//t_order_ListEditorGrid.on('afteredit', t_order_inline_update); // inLine Editing Record
        
        //LOV
        m_customer_DataStore = new Ext.data.Store({
		id: 'm_customer_DataStore',
		proxy: new Ext.data.HttpProxy({
			url: 'index.php?c=c_public_function&m=get_m_customer',
			method: 'POST'
		}),
		baseParams:{start:0, limit: pageS},
		reader: new Ext.data.JsonReader({
			root: 'results',
			totalProperty: 'total',
			id: 'customer_id'
		},[
			{name: 'customer_id', type: 'int', mapping: 'customer_id'},
			{name: 'customer_name', type: 'string', mapping: 'customer_name'}
		]),
		sortInfo:{field: 'customer_name', direction: "ASC"}
	});
        
        m_staff_DataStore = new Ext.data.Store({
		id: 'm_staff_DataStore',
		proxy: new Ext.data.HttpProxy({
			url: 'index.php?c=c_public_function&m=get_m_staff',
			method: 'POST'
		}),
		baseParams:{start:0, limit: pageS},
		reader: new Ext.data.JsonReader({
			root: 'results',
			totalProperty: 'total',
			id: 'staff_id'
		},[
			{name: 'staff_id', type: 'int', mapping: 'staff_id'},
			{name: 'staff_name', type: 'string', mapping: 'staff_name'}
		]),
		sortInfo:{field: 'staff_name', direction: "ASC"}
	});
        

	order_idField= new Ext.form.NumberField({
		id: 'order_idField',
		fieldLabel: 'Order Id ',
                hidden: true,
		allowNegatife : false,
		blankText: '0',
		allowDecimals: false,
		anchor: '95%',
		maskRe: /([0-9]+)$/
	});
	order_codeField= new Ext.form.TextField({
		id: 'order_codeField',
		fieldLabel: 'No Order <font color=red>*</font>',
		maxLength: 20,
		anchor: '95%',
                allowBlank: false
	});
	order_dateField= new Ext.form.DateField({
		id: 'order_dateField',
		fieldLabel: 'Tgl Order <font color=red>*</font>',
		format : 'Y-m-d',
		anchor: '95%',
                allowBlank: false
	});
	order_duedateField= new Ext.form.DateField({
		id: 'order_duedateField',
		fieldLabel: 'Tgl Selesai <font color=red>*</font>',
		format : 'Y-m-d',
		anchor: '95%',
                allowBlank: false
	});
        m_customer_idField= new Ext.form.ComboBox({
		id: 'm_customer_idField',
		fieldLabel: 'Klien <font color=red>*</font>',
		store: m_customer_DataStore,
		mode: 'remote',
		displayField:'customer_name',
		valueField: 'customer_id',
		allowBlank: false,
		editable: true,
		anchor: '95%',
		pageSize: 15,
		triggerAction: 'all'
	});
 	m_staff_idField= new Ext.form.ComboBox({
		id: 'm_staff_idField',
		fieldLabel: 'Marketing <font color=red>*</font>',
		store: m_staff_DataStore,
		mode: 'remote',
		displayField:'staff_name',
		valueField: 'staff_id',
		allowBlank: false,
		editable: true,
		anchor: '95%',
		pageSize: 15,
		triggerAction: 'all'
	});       
	order_statField= new Ext.form.TextField({
		id: 'order_statField',
		fieldLabel: 'Status ',
		maxLength: 1,
			anchor: '95%'
	});
	order_noteField= new Ext.form.TextArea({
		id: 'order_noteField',
		fieldLabel: 'Catatan ',
		maxLength: 200,
			anchor: '95%'
	});

  	/*Fieldset Master*/
	t_order_masterGroup = new Ext.form.FieldSet({
		title: 'Master ',
		autoHeight: true,
		collapsible: true,
		layout:'column',
		labelAlign: 'left',
		items:[
                        {
				columnWidth:0.5,
				layout: 'form',
				border:false,
				items: [order_codeField, order_dateField, order_duedateField, order_noteField] 
			},
                        {
				columnWidth:0.5,
				layout: 'form',
				border:false,
				items: [ m_customer_idField, m_staff_idField, new  Ext.form.Label({html:'Keterangan : <font color=red>*</font>  '+INFO_REQUIRED })] 
			}
                    
                    
                   /* order_idField,
				order_codeField,
				order_dateField,
				order_duedateField,
				m_customer_idField,
				m_staff_idField,
				order_statField,
				order_noteField		,
			   new  Ext.form.Label({html:'Keterangan : <font color=red>*</font>  '+INFO_REQUIRED })
*/
		]
	});


	/*Detail Declaration */
	// Function for json reader of detail
	var t_orderdet_reader=new Ext.data.JsonReader({
		root: 'results',
		totalProperty: 'total',
		id: 'orderdet_id'
	},[
			{name: 'orderdet_id', type: 'int', mapping: 'orderdet_id'},
			{name: 't_order_id', type: 'int', mapping: 't_order_id'},
			{name: 'orderdet_detail', type: 'string', mapping: 'orderdet_detail'},
			{name: 'orderdet_qty', type: 'int', mapping: 'orderdet_qty'},
			{name: 'orderdet_price', type: 'float', mapping: 'orderdet_price'}
	]);
	//eof

	//function for json writer of detail
	var t_orderdet_writer = new Ext.data.JsonWriter({
		encode: true,
		writeAllFields: false
	});
	//eof

	/* Function for Retrieve DataStore of detail*/
	t_orderdet_DataStore = new Ext.data.Store({
		id: 't_orderdet_DataStore',
		proxy: new Ext.data.HttpProxy({
			url: 'index.php?c=c_t_order&m=detail_t_orderdet_list',
			method: 'POST'
		}),
		reader: t_orderdet_reader,
		baseParams:{master_id: get_pk_id()},
		sortInfo:{field: 'orderdet_id', direction: "ASC"}
	});
	/* End of Function */

	//function for editor of detail
	var editor_t_orderdet= new Ext.ux.grid.RowEditor({
        saveText: 'Update'
    });
	//eof

	//declaration of detail coloumn model
	t_orderdet_ColumnModel = new Ext.grid.ColumnModel(
		[
		{
			header: 'Orderdet Id',
			dataIndex: 'orderdet_id',
			width: 150,
			sortable: true,
                        hidden: true,
			editor: new Ext.form.NumberField({
				allowDecimals: false,
					allowNegative: false,
				blankText: '0',
				maxLength: 11,
				maskRe: /([0-9]+)$/
			})
		},
		{
			header: 'T Order Id',
			dataIndex: 't_order_id',
			width: 150,
			sortable: true,
                        hidden: true,
			editor: new Ext.form.NumberField({
				allowDecimals: false,
					allowNegative: false,
				blankText: '0',
				maxLength: 11,
				maskRe: /([0-9]+)$/
			})
		},
		{
			header: 'Orderdet Detail',
			dataIndex: 'orderdet_detail',
			width: 150,
			sortable: true,
			editor: new Ext.form.TextArea({
					height: 5
			})
		},
		{
			header: 'Orderdet Qty',
			dataIndex: 'orderdet_qty',
			width: 150,
			sortable: true,
			editor: new Ext.form.NumberField({
				allowDecimals: false,
					allowNegative: false,
				blankText: '0',
				maxLength: 11,
				maskRe: /([0-9]+)$/
			})
		},
		{
			header: 'Orderdet Price',
			dataIndex: 'orderdet_price',
			width: 150,
			sortable: true,
			editor: new Ext.form.NumberField({
				allowDecimals: true,
					allowNegative: false,
				blankText: '0',
				maxLength: 22,
				maskRe: /([0-9]+)$/
			})
		}]
	);
	t_orderdet_ColumnModel.defaultSortable= true;
	//eof

    /* Button of Detail */
    t_orderdet_gbtn_add=new Ext.Button({
	    text: BTN_ADD_TITLE,
		tooltip: BTN_ADD_TOOLTIP,
		iconCls:'icon-adds',
		handler: t_orderdet_add
    });

    t_orderdet_gbtn_delete=new Ext.Button({
	    text: BTN_DELETE_TITLE,
		tooltip: BTN_DELETE_TOOLTIP,
		iconCls:'icon-delete',
		handler: t_orderdet_confirm_delete
    });
	/*EOF */

	//declaration of detail list editor grid
	t_orderdet_ListEditorGrid =  new Ext.grid.EditorGridPanel({
		id: 't_orderdet_ListEditorGrid',
		el: 'fp_t_orderdet',
		title: TITLE_LIST_DETAIL,
		height: 250,
		width: 690,
		autoScroll: true,
		store: t_orderdet_DataStore,
		colModel: t_orderdet_ColumnModel,
		enableColLock:false,
		region: 'center',
        margins: '0 5 5 5',
		plugins: [editor_t_orderdet],
		frame: true,
		clicksToEdit:2,
		selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
		viewConfig: { forceFit:true},
		tbar: [
		t_orderdet_gbtn_add, '-',t_orderdet_gbtn_delete
		]
	});
	//eof


	//function of detail add
	function t_orderdet_add(){
		var edit_t_orderdet= new t_orderdet_ListEditorGrid.store.recordType({
			orderdet_id	:'',
			t_order_id	:'',
			orderdet_detail	:'',
			orderdet_qty	:'',
			orderdet_price	:''
		});
		editor_t_orderdet.stopEditing();
		t_orderdet_DataStore.insert(0, edit_t_orderdet);
		t_orderdet_ListEditorGrid.getView().refresh();
		t_orderdet_ListEditorGrid.getSelectionModel().selectRow(0);
		editor_t_orderdet.startEditing(0);
	}

	//function for refresh detail
	function refresh_t_orderdet(){
		t_orderdet_DataStore.commitChanges();
		t_orderdet_ListEditorGrid.getView().refresh();
	}
	//eof


	/* Function for Delete Confirm of detail */
	function t_orderdet_confirm_delete(){
		// only one record is selected here
		if(t_orderdet_ListEditorGrid.selModel.getCount() == 1){
			Ext.MessageBox.confirm('Confirmation',CONFIRM_DELETE, t_orderdet_delete);
		} else if(t_orderdet_ListEditorGrid.selModel.getCount() > 1){
			Ext.MessageBox.confirm('Confirmation',CONFIRM_MULTI_DELETE, t_orderdet_delete);
		} else {
			Ext.MessageBox.show({
				title: 'Warning',
				msg: FAILED_DELETE_SELECTED,
				buttons: Ext.MessageBox.OK,
				animEl: 'save',
				icon: Ext.MessageBox.WARNING
			});
		}
	}
	//eof

	//function for Delete of detail
	function t_orderdet_delete(btn){
		if(btn=='yes'){
			var s = t_orderdet_ListEditorGrid.getSelectionModel().getSelections();
			for(var i = 0, r; r = s[i]; i++){
				t_orderdet_DataStore.remove(r);
			}
		}
	}
	//eof

	//event on update of detail data store
	t_orderdet_DataStore.on('update', refresh_t_orderdet);

	t_order_btn_Save=new Ext.Button({
		text: BTN_SAVE,
		handler: t_order_save
	})

	/* Function for retrieve create Window Panel*/
	t_order_saveForm = new Ext.FormPanel({
		labelAlign: 'left',
		bodyStyle:'padding:5px',
		autoHeight:true,
		width: 700,
		items: [t_order_masterGroup,t_orderdet_ListEditorGrid],
		buttons: [t_order_btn_Save
			,{
				text: BTN_CANCEL,
				handler: function(){
					t_order_reset_form();
					t_order_saveWindow.hide();
				}
			}
		]
	});


	/* Function for retrieve create Window Form */
	t_order_saveWindow= new Ext.Window({
		id: 't_order_saveWindow',
		title: TITLE_FORM+' T Order',
		closable:true,
		closeAction: 'hide',
		autoWidth: true,
		autoHeight: true,
		x:0,
		y:0,
		plain:true,
		layout: 'fit',
		modal: true,
		renderTo: 'elwindow_t_order_save',
		items: t_order_saveForm
	});
	/* End Window */

/* Function for action list search */
	function t_order_list_search(){

		var order_id_search=null;
		var order_code_search=null;
		var order_date_search_date="";
		var order_duedate_search_date="";
		var m_customer_id_search=null;
		var m_staff_id_search=null;
		var order_stat_search=null;
		var order_note_search=null;

		if(order_idSearchField.getValue()!==null){order_id_search=order_idSearchField.getValue();}
		if(order_codeSearchField.getValue()!==null){order_code_search=order_codeSearchField.getValue();}
		if(order_dateSearchField.getValue()!==""){order_date_search_date=order_dateSearchField.getValue().format('Y-m-d');}
		if(order_duedateSearchField.getValue()!==""){order_duedate_search_date=order_duedateSearchField.getValue().format('Y-m-d');}
		if(m_customer_idSearchField.getValue()!==null){m_customer_id_search=m_customer_idSearchField.getValue();}
		if(m_staff_idSearchField.getValue()!==null){m_staff_id_search=m_staff_idSearchField.getValue();}
		if(order_statSearchField.getValue()!==null){order_stat_search=order_statSearchField.getValue();}
		if(order_noteSearchField.getValue()!==null){order_note_search=order_noteSearchField.getValue();}

		t_order_DataStore.baseParams = {
			task: 'SEARCH',
			order_id	:	order_id_search,
			order_code	:	order_code_search,
			order_date	:	order_date_search_date,
			order_duedate	:	order_duedate_search_date,
			m_customer_id	:	m_customer_id_search,
			m_staff_id	:	m_staff_id_search,
			order_stat	:	order_stat_search,
			order_note	:	order_note_search
		};

		t_order_DataStore.reload({params: {start: 0, limit: pageS}});
	}

	/* Function for reset search result */
	function t_order_reset_search(){
		t_order_DataStore.baseParams = { task: 'LIST' };
		t_order_DataStore.reload({params: {start: 0, limit: pageS}});
		t_order_searchWindow.close();
	};
	/* End of Fuction */

	/* Field for search */
	/* Identify  order_id Search Field */
	order_idSearchField= new Ext.form.NumberField({
		id: 'order_idSearchField',
		fieldLabel: 'Order Id',
                hidden: true,
		allowNegatife : false,
		blankText: '0',
		allowDecimals: false,
		anchor: '95%',
		maskRe: /([0-9]+)$/
	});
	/* Identify  order_code Search Field */
	order_codeSearchField= new Ext.form.TextField({
		id: 'order_codeSearchField',
		fieldLabel: 'Order Code',
		maxLength: 20,
		anchor: '95%'
	});
	/* Identify  order_date Search Field */
	order_dateSearchField= new Ext.form.DateField({
		id: 'order_dateSearchField',
		fieldLabel: 'Order Date',
		format : 'Y-m-d'
	});
	/* Identify  order_duedate Search Field */
	order_duedateSearchField= new Ext.form.DateField({
		id: 'order_duedateSearchField',
		fieldLabel: 'Order Duedate',
		format : 'Y-m-d'
	});
	/* Identify  m_customer_id Search Field */
	m_customer_idSearchField= new Ext.form.NumberField({
		id: 'm_customer_idSearchField',
		fieldLabel: 'M Customer Id',
		allowNegatife : false,
		blankText: '0',
		allowDecimals: false,
		anchor: '95%',
		maskRe: /([0-9]+)$/
	});
	/* Identify  m_staff_id Search Field */
	m_staff_idSearchField= new Ext.form.NumberField({
		id: 'm_staff_idSearchField',
		fieldLabel: 'M Staff Id',
		allowNegatife : false,
		blankText: '0',
		allowDecimals: false,
		anchor: '95%',
		maskRe: /([0-9]+)$/
	});
	/* Identify  order_stat Search Field */
	order_statSearchField= new Ext.form.TextField({
		id: 'order_statSearchField',
		fieldLabel: 'Order Stat',
		maxLength: 1,
		anchor: '95%'
	});
	/* Identify  order_note Search Field */
	order_noteSearchField= new Ext.form.TextField({
		id: 'order_noteSearchField',
		fieldLabel: 'Order Note',
		maxLength: 200,
		anchor: '95%'
	});

	/* Function for retrieve search Form Panel */
	t_order_searchForm = new Ext.FormPanel({
		labelAlign: 'left',
		layout:'form',
		bodyStyle:'padding:5px',
		autoHeight:true,
		frame: true,
		width: 500,
		items: [order_idSearchField,
				order_codeSearchField,
				order_dateSearchField,
				order_duedateSearchField,
				m_customer_idSearchField,
				m_staff_idSearchField,
				order_statSearchField,
				order_noteSearchField
		 ],
		buttons: [{
				text: BTN_SEARCH,
				handler: t_order_list_search
			},{
				text: BTN_CANCEL,
				handler: function(){
					t_order_searchWindow.hide();
				}
			}
		]
	});
    /* End of Function */

	/* Function for retrieve search Window Form, used for andvaced search */
	t_order_searchWindow = new Ext.Window({
		title: TITLE_FORM_SEARCH+'t_order',
		closable:true,
		closeAction: 'hide',
		autoWidth: true,
		autoHeight: true,
		plain:true,
		layout: 'fit',
		x: 0,
		y: 0,
		modal: true,
		renderTo: 'elwindow_t_order_search',
		items: t_order_searchForm
	});
    /* End of Function */

  	/* Function for Displaying  Search Window Form */
	function display_form_search_window(){
		if(!t_order_searchWindow.isVisible()){
			t_order_searchWindow.show();
		} else {
			t_order_searchWindow.toFront();
		}
	}
  	/* End Function */

	/* Function for print List Grid */
	function t_order_print(){
		var searchquery = "";
		var order_id_print=null;
		var order_code_print=null;
		var order_date_print_date="";
		var order_duedate_print_date="";
		var m_customer_id_print=null;
		var m_staff_id_print=null;
		var order_stat_print=null;
		var order_note_print=null;

		if(t_order_DataStore.baseParams.query!==null){searchquery = t_order_DataStore.baseParams.query;}
		if(t_order_DataStore.baseParams.order_id!==null){order_id_print = t_order_DataStore.baseParams.order_id;}
		if(t_order_DataStore.baseParams.order_code!==null){order_code_print = t_order_DataStore.baseParams.order_code;}
		if(t_order_DataStore.baseParams.order_date!==""){order_date_print_date = t_order_DataStore.baseParams.order_date;}
		if(t_order_DataStore.baseParams.order_duedate!==""){order_duedate_print_date = t_order_DataStore.baseParams.order_duedate;}
		if(t_order_DataStore.baseParams.m_customer_id!==null){m_customer_id_print = t_order_DataStore.baseParams.m_customer_id;}
		if(t_order_DataStore.baseParams.m_staff_id!==null){m_staff_id_print = t_order_DataStore.baseParams.m_staff_id;}
		if(t_order_DataStore.baseParams.order_stat!==null){order_stat_print = t_order_DataStore.baseParams.order_stat;}
		if(t_order_DataStore.baseParams.order_note!==null){order_note_print = t_order_DataStore.baseParams.order_note;}

		Ext.Ajax.request({
		waitMsg: 'Please Wait...',
		url: 'index.php?c=c_t_order&m=get_action',
		params: {
			task: "PRINT",
		  	query: searchquery,
			order_id : order_id_print,
			order_code : order_code_print,
		  	order_date : order_date_print_date,
		  	order_duedate : order_duedate_print_date,
			m_customer_id : m_customer_id_print,
			m_staff_id : m_staff_id_print,
			order_stat : order_stat_print,
			order_note : order_note_print,
		  	currentlisting: t_order_DataStore.baseParams.task
		},
		success: function(response){
		  	var result=eval(response.responseText);
		  	switch(result){
		  	case 1:
				window.open('./print/t_order_printlist.html','t_orderlist','height=600,width=800,resizable=1,scrollbars=0, menubar=0');
				break;
		  	default:
				Ext.MessageBox.show({
					title: 'Warning',
					msg: FAILED_PRINT,
					buttons: Ext.MessageBox.OK,
					animEl: 'save',
					icon: Ext.MessageBox.WARNING
				});
				break;
		  	}
		},
		failure: function(response){
		  	var result=response.responseText;
			Ext.MessageBox.show({
			   title: 'Error',
			   msg: FAILED_CONNECTION,
			   buttons: Ext.MessageBox.OK,
			   animEl: 'database',
			   icon: Ext.MessageBox.ERROR
			});
		}
		});
	}
	/* Enf Function */

	/* Function for print Export to Excel Grid */
	function t_order_export_excel(){
		var searchquery = "";
		var order_id_2excel=null;
		var order_code_2excel=null;
		var order_date_2excel_date="";
		var order_duedate_2excel_date="";
		var m_customer_id_2excel=null;
		var m_staff_id_2excel=null;
		var order_stat_2excel=null;
		var order_note_2excel=null;

		if(t_order_DataStore.baseParams.query!==null){searchquery = t_order_DataStore.baseParams.query;}
		if(t_order_DataStore.baseParams.order_id!==null){order_id_2excel = t_order_DataStore.baseParams.order_id;}
		if(t_order_DataStore.baseParams.order_code!==null){order_code_2excel = t_order_DataStore.baseParams.order_code;}
		if(t_order_DataStore.baseParams.order_date!==""){order_date_2excel_date = t_order_DataStore.baseParams.order_date;}
		if(t_order_DataStore.baseParams.order_duedate!==""){order_duedate_2excel_date = t_order_DataStore.baseParams.order_duedate;}
		if(t_order_DataStore.baseParams.m_customer_id!==null){m_customer_id_2excel = t_order_DataStore.baseParams.m_customer_id;}
		if(t_order_DataStore.baseParams.m_staff_id!==null){m_staff_id_2excel = t_order_DataStore.baseParams.m_staff_id;}
		if(t_order_DataStore.baseParams.order_stat!==null){order_stat_2excel = t_order_DataStore.baseParams.order_stat;}
		if(t_order_DataStore.baseParams.order_note!==null){order_note_2excel = t_order_DataStore.baseParams.order_note;}

		Ext.Ajax.request({
		waitMsg: 'Please Wait...',
		url: 'index.php?c=c_t_order&m=get_action',
		params: {
			task: "EXCEL",
		  	query: searchquery,
			order_id : order_id_2excel,
			order_code : order_code_2excel,
		  	order_date : order_date_2excel_date,
		  	order_duedate : order_duedate_2excel_date,
			m_customer_id : m_customer_id_2excel,
			m_staff_id : m_staff_id_2excel,
			order_stat : order_stat_2excel,
			order_note : order_note_2excel,
		  	currentlisting: t_order_DataStore.baseParams.task
		},
		success: function(response){
		  	var result=eval(response.responseText);
		  	switch(result){
		  	case 1:
				win = window.location=('./export2excel.php');
				break;
		  	default:
				Ext.MessageBox.show({
					title: 'Warning',
					msg: FAILED_EXCEL,
					buttons: Ext.MessageBox.OK,
					animEl: 'save',
					icon: Ext.MessageBox.WARNING
				});
				break;
		  	}
		},
		failure: function(response){
		  	var result=response.responseText;
			Ext.MessageBox.show({
			   title: 'Error',
			   msg: FAILED_CONNECTION,
			   buttons: Ext.MessageBox.OK,
			   animEl: 'database',
			   icon: Ext.MessageBox.ERROR
			});
		}
		});
	}
	/*End of Function */

	/* Show Hide control for permission */
	var pattr=new RegExp("R");
	var pattc=new RegExp("C");
	var pattu=new RegExp("U");
	var pattd=new RegExp("D");

	if(pattc.test(PERMISSION)==false){
		t_order_gbtn_add.setVisible(false);
		t_orderdet_gbtn_add.setVisible(false);
	}else{
		t_order_gbtn_add.setVisible(true);
		t_orderdet_gbtn_add.setVisible(true);
	}

	if(pattu.test(PERMISSION)==false){
		t_order_gbtn_update.setVisible(false);
		t_order_cbtn_update.setVisible(false);
	}else{
		t_order_gbtn_update.setVisible(true);
		t_order_cbtn_update.setVisible(true);
	}

	if(pattd.test(PERMISSION)==false){
		t_order_gbtn_delete.setVisible(false);
		t_order_cbtn_delete.setVisible(false);
		t_orderdet_gbtn_delete.setVisible(false);
	}else{
		t_order_gbtn_delete.setVisible(true);
		t_order_cbtn_delete.setVisible(true);
		t_orderdet_gbtn_delete.setVisible(true);
	}

	if(pattc.test(PERMISSION)==false && pattu.test(PERMISSION)==false){
		t_order_btn_Save.setVisible(false);
	}else{
		t_order_btn_Save.setVisible(true);
	}
});
	</script>
<body>
<div>
	<div class="col">
        <div id="fp_t_order"></div>
        <div id="fp_t_orderdet"></div>
		<div id="elwindow_t_order_save"></div>
        <div id="elwindow_t_order_search"></div>
    </div>
</div>
</body>
</html>